package com.richapp.launcher.scene.conditions.sensor;

import com.richapp.launcher.database.system.mode.DeviceModel;
import com.richapp.launcher.scene.abstracts.SceneAbstractSensorConditions;
import com.richapp.launcher.scene.interfaces.ISceneConditions;
import com.richapp.launcher.scene.interfaces.ISceneSensorConditions;

public class SceneSensorAlarmConditions extends SceneAbstractSensorConditions {

	
	/**
	 * 报警类设备
	 * 有报警 true
	 * 无报警 false
	 */
	
	public static final String SCENE_ALARM_CHECK_TYPE_ALARM = "true";
	public static final String SCENE_ALARM_CHECK_TYPE_NOT_ALARM = "false";
	
	private String checkAlarmValue;
	
	public SceneSensorAlarmConditions() {
		
	}

	@Override
	public int getConditionType() {
		return ISceneConditions.SCENE_CONDITION_TYPE_SENSOR;
	}

	@Override
	public int getConditionSubType() {
		return ISceneSensorConditions.SCENE_CONDITION_SUB_TYPE_SENSOR_AIR;
	}

	@Override
	public boolean checkCondition(String sceneName) {
		boolean checkFlag=false;
		DeviceModel device = getDevice();
		if(device != null){
			boolean alarmFlag = (System.currentTimeMillis() - device.getLastAlarmTime()) < 2000;
			if(alarmFlag == Boolean.getBoolean(checkAlarmValue)){
				checkFlag = true;
			}
		}
		return checkFlag;
	}

	public String getCheckAlarmValue() {
		return checkAlarmValue;
	}

	public void setCheckAlarmValue(String checkAlarmValue) {
		this.checkAlarmValue = checkAlarmValue;
	}
}
